package com.ht.medicaltreatment.adapter

import android.view.View
import android.widget.ImageView
import androidx.constraintlayout.widget.Group
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.CheckGroupBeanRfidSample

class GroupBloodAdapter : BaseQuickAdapter<CheckGroupBeanRfidSample,BaseViewHolder>(R.layout.item_group_blood_layout){

    init {
        addChildClickViewIds(R.id.imgTop,R.id.imgTop2)
    }

    override fun convert(holder: BaseViewHolder, item: CheckGroupBeanRfidSample) {
        val groupSmall = holder.getView<Group>(R.id.group1)
        val groupLong = holder.getView<Group>(R.id.group2)
        //长管顶部图标
        val imgTop2 = holder.getView<ImageView>(R.id.imgTop2)
        //短管顶部图标
        val imgTop = holder.getView<ImageView>(R.id.imgTop)
        val changShiGuan = holder.getView<ImageView>(R.id.imgSG2)
        val duanShiGuan = holder.getView<ImageView>(R.id.imgSG)
        if(item.sampleCategoryDict.name.contains("Blood") || item.sampleCategoryDict.name == "全血"){
            //长管
            groupSmall.visibility = View.GONE
            groupLong.visibility = View.VISIBLE
            holder.setText(R.id.tvNameC,item.name)
            imgTop.visibility = View.GONE
            if(item.checkType == 1){
                changShiGuan.setBackgroundResource(R.drawable.bg_green_check_left)
                imgTop2.visibility = View.GONE
            }else{
                changShiGuan.setBackgroundResource(R.drawable.icon_check_left)
                imgTop2.visibility = View.VISIBLE
            }
        }else{
            //短管
            groupSmall.visibility = View.VISIBLE
            groupLong.visibility = View.GONE
            holder.setText(R.id.tvNameD,item.name)
            imgTop2.visibility = View.GONE
            if(item.checkType == 1){
                duanShiGuan.setBackgroundResource(R.drawable.bg_green_center)
                imgTop.visibility = View.GONE
            }else{
                duanShiGuan.setBackgroundResource(R.drawable.icon_check_center)
                imgTop.visibility = View.VISIBLE
            }
        }
    }

}
